home *** CD-ROM | disk | FTP | other *** search
/ Meeting Pearls 1 / Meeting Pearls Vol 1 (1994).iso / installed_progs / text / faqs / linux.howto.printing.part2 < prev    next >
Encoding:
Internet Message Format  |  1994-03-18  |  58.9 KB

  1. Subject: Linux Printing HOWTO (Part 2/2)
  2. Newsgroups: comp.os.linux.announce,comp.os.linux.admin,comp.answers,news.answers
  3. From: gtaylor@cs.tufts.edu (Grant Taylor)
  4. Date: 16 Mar 1994 05:54:36 GMT
  5.  
  6. Archive-name: linux/howto/printing/part2
  7. Last-Modified: 22 Feb 94
  8.  
  9. [This is part 2/2 of the Printing HOWTO]
  10.  
  11. 3.2 What lpr and lpd do
  12. =======================
  13.  
  14.    Most Un*x systems use `lpd' (or the System V variant `lp'), the line
  15. printer daemon, and friends to spool print jobs and run them through
  16. all needed filters.  While line printers are certainly on their way
  17. out, spooling print jobs and running them through filters is definitely
  18. a convenient thing.  Thus lpr.  (subliminal note: *PLEASE* find and
  19. read the `lpr', `lpd', `printcap', `lpc', `lpq', and `lprm' man pages.
  20. They are in the source dist of the net-2, if you haven't got them.)
  21.  
  22. 3.3 Getting hold of lpd
  23. =======================
  24.  
  25.    Lpd and family are available in several places.  The new Linux net-2
  26. package contains a working BSD-style lpd (although it has a couple of
  27. bugs and Makefile installs the binaries with the wrong permissions).  I
  28. now use this one with my stock 0.99pl14 kernel after following the
  29. directions in Matt Welsh's Net-2 HOWTO to get my NET-2 going (you only
  30. need loopback). Most people (and this document) consider this to be
  31. *the* Linux lpd package. A slightly debugged version incorporating
  32. patches from earlier releases of this HOWTO is also available in:
  33. `tsx-11.mit.edu:/pub/linux/packages/net/new-net-2/lpd-590p?.tar.gz'
  34.  
  35.    Some of the prepackaged Linux distributions have a very poor record
  36. with respect to having a working lpd packages so don't be shy of
  37. getting a new one if you seem to be having trouble.
  38.  
  39.    Fans of the SysV lp package should consider getting plp (however this
  40. HOWTO contains no information on that package)
  41.  
  42.    An lpd binary package which can be coaxed into working with the old
  43. net things (pre 0.99pl10 kernel) may still be around but you'll probably
  44. find it a bit shakey and you really should update your kernel.  Note a
  45. subtle difference between the two versions: the old one placed lock
  46. files and such in `/var/spool', while the net-2 version requires the
  47. directory `/var/spool/lpd' to exist for its lock file.
  48.  
  49.    You will need to edit `/etc/printcap' to configure lpd to use your
  50. printer. Setting up lpd to accept PostScript and print it is not very
  51. difficult; simply make a shell script filter. See Also: Writing lpd
  52. filters
  53.  
  54.    Setting up lpd correctly is definitely worth the trouble if you are
  55. going to do any printing at all.  Of course, if all you ever print is
  56. the occasional man page or instruction book, then you can probably get
  57. by without it (but even then it's nice).
  58.  
  59.    Ghostscript 2.6.x also comes with a complicated script and utilities
  60. to generate printcap entries and manage multiple types of queues for a
  61. printer.  I have not tested these, but I assume they can be made to
  62. work.  If you are in a large-scale environment with varied printing
  63. needs, these may be worth a look.
  64.  
  65. 3.4 Where Do The Files Go And What Should Their Permissions Be?
  66. ===============================================================
  67.  
  68.    There is quite a bit of variation between the various releases but
  69. I'll try where possible to offer solutions that are universally
  70. applicable. Start `lpd' in your `/etc/rc' or `/etc/rc.local' (usually
  71. in `/etc/rc.local' after you start `syslogd' (if you use `syslogd')).
  72.  
  73.    Set the group fields of the file permissons/ownership as follows:
  74.  
  75.      -rwxr-sr--   1 root     lp          37892 Nov 19 23:32 /etc/lpd
  76.      -rwxr-sr-x   1 root     lp          21508 Nov 19 23:32 /usr/bin/lpc
  77.      -rwsr-sr-x   1 root     lp          17412 Nov 19 23:32 /usr/bin/lpq
  78.      -rwxr-sr-x   1 root     lp          17412 Nov 19 23:32 /usr/bin/lpr
  79.      -rwxr-sr-x   1 root     lp          17412 Nov 19 23:32 /usr/bin/lprm
  80.      -rwxr-xr-x   1 root     lp           2816 May 10 13:37 /usr/bin/lptest
  81.      
  82.      ...and for each of the spool directories listed in the sd fields of
  83.      /etc/printcap...
  84.      
  85.      /var/spool/lpd:
  86.      total 5
  87.      drwxrwxr-x   2 root     lp           1024 May 18 23:00 .
  88.      drwxr-xr-x  11 root     root         1024 Feb 19 20:56 ..
  89.      -rw-rw-r--   1 root     lp              4 May 18 23:00 .seq
  90.      -rw-rw-r--   1 root     lp             18 May 18 23:00 lock
  91.      -rw-rw-r--   1 root     lp             25 May 18 23:00 status
  92.  
  93.    Note these 3 files are created by lpr and lpd so if you've never run
  94. these they will be absent. With some versions of the lpd package you
  95. had to touch them into being or they would be created with the wrong
  96. permissions but this bug seems to have been fixed.
  97.  
  98.    In older versions the group id was `daemon' not `lp'. There's also a
  99. named socket but `lpd' creates/deletes it as needed. Also you may find
  100. the uid is sometimes set to `daemon' or `lp' rather than `root' but
  101. this is of no consequence except on setuid binaries.
  102.  
  103.    These permissions are the most pedantic so don't be surprised if
  104. your system works with different permissions. On the other hand if lpd
  105. is not working for you and you have different permissions please try
  106. these before mailing us or posting to usenet. (This may sound obvious
  107. but you'd be amazed how much mail I've had from people with the
  108. permissions set wrong).
  109.  
  110.    People tell me that `lpr' must be setuid(root) but I've not seen
  111. evidence that this is really the case as long as the file permissions on
  112. the spool queues are right. Still as far as I know `lpr' is designed to
  113. be secure when installed setuid(root). This allows an alternative
  114. (sloppy) approach: just make `lpr' and `lprm' setuid(root) then you can
  115. almost forget the file permissions on the spool queues!
  116.  
  117.    You're free to choose different directories for the executables on
  118. your system (notably `lpc' is usually in `/etc' (or `/usr/sbin') even
  119. though it has commands that are useful to non-root). Of course since
  120. you are free to do this it implies the person who made up your
  121. distribution was also free to do so, so be carefull to make sure you
  122. delete old components when you install new ones.
  123.  
  124.    The master lpd lock file is fixed at compile time to be
  125. `/var/spool/lpd/lpd.lock' so you must have a `/var/spool/lpd directory'
  126. even if you choose not to keep your spool queue there. In the older
  127. binaries the lock file was `/usr/spool/lpd.lock' so this was not an
  128. issue.
  129.  
  130.    My advise is to keep your primary spool queue in `/usr/spool/lpd' and
  131. make `/var' a symlink to `usr' or keep it in `/var/spool/lpd' and make
  132. `/usr/spool' a symlink to `../var/spool'. This gives the greatest
  133. compatibility with the pathnames that are compiled into the various
  134. distributed binaries. Note that having a separate `/var' filesystem
  135. avoids the problem of your `/usr' filesystem filling up as a result of
  136. stuff in spool queues.
  137.  
  138.    The main configuration file is `/etc/printcap'. Network printing also
  139. uses `/etc/hosts.allow' and `/etc/hosts.lpd'.
  140.  
  141.    By now everyone should have libraries and binaries that look for
  142. config files in `/etc'. If you chose to keep your configs somewhere else
  143. (`/conf' or `/usr/etc' for example) then `/etc' must contain a symlink
  144. to the real file. If you still have a system which looks for files in
  145. `/usr/etc' or `/etc/inet' your system is way out of date and you should
  146. upgrade.
  147.  
  148. 3.5 lpd not working
  149. ===================
  150.  
  151.    If `ps ax' does not reveal a `lpd' then you daemon has died (or was
  152. never started) - usually a sign that it couldn't create its lockfile,
  153. or was unable to find `/etc/services'.  (This will happen if you tried
  154. to start it before all your filesystems were mounted).
  155.  
  156.    If `lpr' works only for root then you've probably got a permission
  157. problem.
  158.  
  159.    If you cant even `cat' files to the printer then you may be using
  160. the wrong device name for the printer in `/etc/printcap' See Also: Printer
  161. device names or you may need to fiddle with `tunelp'.  See Also: hardware
  162. and drivers.
  163.  
  164.    If you get "jobs queued, but cannot start daemon" or "lpc: connect:
  165. No such file or directory" while `lpd' is running then you are having
  166. trouble with the socket connection to `lpd'. "start" in the context of
  167. this error really means "wake". This problem has come and gone
  168. thoughout the history of Linux - I don't really understand this but it
  169. stems from an erroneous interaction between the networking stuff and
  170. "Unix domain" (non-network) sockets. Usually it has only shown up when
  171. the network is incorrectly configured. If you're not really on a
  172. network it is usually adequate just to have the following somewhere in
  173. your startup.
  174.  
  175.      ifconfig lo localhost
  176.      route add localhost
  177.  
  178.    You'll also need to have the `/etc/hosts' file. There's no need to
  179. run any daemons.
  180.  
  181.    There is second and much more understandable way to produce this
  182. error - use a mixture of components from different releases of lpd that
  183. use different names for the Unix domain socket (new stuff uses
  184. `/tmp/.printer', obsolete stuff `/dev/printer'). (For some time SLS was
  185. released this way).
  186.  
  187.    At the time of writing I am quite unable to reproduce this error - I
  188. am using my debugged version of the net-2 lpd compiled with gcc-2.4.5
  189. and libc-4.4.4 on kernel 0.99.14.
  190.  
  191. 3.6 Where Do I Get A Printcap For Printer Model xxxxx?
  192. ======================================================
  193.  
  194.    This question is essentially meaningless so please don't ask it on
  195. usenet See Also: The Semantics of /etc/printcap.
  196.  
  197. 3.7 The Semantics of `/etc/printcap'
  198. ====================================
  199.  
  200.    Given the similarity in appearance and name between `/etc/termcap'
  201. and `/etc/printcap' one could be forgiven for assuming that they
  202. contain analogous infomation. This is not the case. Whereas
  203. `/etc/termcap' contains informations about terminal *types* - (mostly
  204. escape seqences) printcap contains information about *specific*
  205. printers (like the directory that holds the spool queue, the device
  206. name of the printer and what room it's in). The information about a
  207. printer model's escape sequences and so on are held in the various
  208. "filters" which are programs called by `lpd' to drive the printer.
  209. `/etc/printcap' simply gives the locations of these filters.  For
  210. details RTFM(printcap). [Alternatively the net-HOWTO has a summary of
  211. some of the more important fields.]
  212.  
  213.    One last point - you should always specify `suppress header' `:sh:'
  214. unless you have a *text* (not PostScript) printer and want banners. On
  215. a text printer they are usually a waste of time and paper. On a
  216. PostScript printer they usually stop your printer working.  See Also:
  217. Burst/banner pages.
  218.  
  219. 3.8 The Syntax of `/etc/printcap'
  220. =================================
  221.  
  222.    Ideally RTFM(termcap) (yes, I said *termcap*) but since most people
  223. don't have TFM(termcap) here are the essentials.
  224.  
  225.    Lines starting with `#' are comments (as you might have guessed).
  226.  
  227.    For each printer usable from the `lpr' command on your system there
  228. is one logical line in the file. For the sake of readability each
  229. logical line may be spread over several physical lines by making the
  230. last character on all but the last physical line a backslash.
  231.  
  232.    Each logical line has the following format:
  233.  
  234.      NAME1|NAME2|NAME3:STRING_CAPABILITY=STRING:\
  235.             :NUMERIC_CAPABILITY#NUMBER:BOOLEAN_CAPABILITY:
  236.  
  237.    The leading spaces and colon on the second line are for readability
  238. only.
  239.  
  240.    A printer can have as many names as you like but conventionally the
  241. final name is used as a longhand description of the printer. (Still
  242. people are free to say `lpr -P "grotty teletype in room 213"' if that's
  243. the description you've given.) One of the names of your default printer
  244. must be `lp'.
  245.  
  246.    The list of capabilities can be as long as needed and the order is
  247. not significant. Each "capability" is denoted by a two character code.
  248. (The name "capability" comes form the file format's termcap heritage -
  249. parameter or attribute would be a more sensible terms.) [Note from Ross
  250. Biro: capabilities with 3 character names don't work properly which is
  251. why the serial port stuff in the old binaries failed.]  Capabilities
  252. having string value and have a `=' delimiter between the capability
  253. name and the value while those having a numeric value use a `#'
  254. (actually they can use either a `#' or an `='). Boolean "capabilities"
  255. are true if they appear in the list and false if they do not.
  256.  
  257.    Special characters in a string value can be expressed using
  258. backslash-escaped sequences as in C; in addition, `\E' stands for ESC.
  259. `^' is also a kind of escape character; `^' followed by CHAR stands for
  260. the control-equivalent of CHAR.  Thus, `^a' stands for the character
  261. control-a, just like `\001'. `\' and `^' themselves can be represented
  262. as `\\' and `\^' respectively. `\:' for `:' seems to work but the
  263. source code contains a warning that it can confuse the parser and
  264. `\072' is a better idea.
  265.  
  266.    Example:
  267.      lp|bam|Epson FX-80:lp=/dev/lp1:sd=/usr/spool/lp1:sh:mx#0:\
  268.              :df=/usr/local/lib/magic-filter/lp.df:\
  269.              :if=/usr/local/lib/magic-filter/lp.if:
  270.  
  271.    The printer's name is `lp' (this is the printer that `lpr' uses by
  272. default). It's also known as `bam' or `"Epson FX-80"'.
  273.  
  274.    The printer is on `/dev/lp1' (aka AT-bus LPT1:). I don't want a burst
  275. page. I don't want a file length limit. Files queued by `lpr -d' are
  276. passed through `/usr/local/lib/magic-filter/lp.df' and those queued by
  277. `lpr' through `/usr/local/lib/magic-filter/lp.lf'.
  278.  
  279.    See also the next section.
  280.  
  281. 3.9 An `/etc/printcap' gotcha
  282. =============================
  283.  
  284.    Two `/etc/printcap' files can look identical and yet one works and
  285. the other doesn't.
  286.  
  287.    See if `lpc stat' reports a printer called ` :'. The last character
  288. on a continued line must be a backslash. If there are whitespace
  289. characters after the backslash then it doesn't register the next line
  290. as a continuation.
  291.  
  292. 3.10 The Minimum /etc/printcap
  293. ==============================
  294.  
  295.    This is a silly question but it is frequently asked. The answer is
  296. `lp:sh' (that's 6 bytes including the required linefeed character on
  297. the end). To use this `/etc/printcap' you must make `/dev/lp' a symlink
  298. to your printer and create your spool queue directory as
  299. `/usr/spool/lpd'.  (You might think that if you wanted banner pages you
  300. could loose the `:sh' but the termcap syntax requires at least one
  301. capability per entry).
  302.  
  303. 3.11 How to prevent the `Staircase Effect'
  304. ==========================================
  305.  
  306.    Un*x terminates each line of a file with a linefeed but not a
  307. carriage return so taken literally a Un*x text file printed on an ASCII
  308. device will start each line below the end of the previous line.  Some
  309. printers can be set to treat "linefeed" as "carriage return, linefeed",
  310. others can't. If yours can then do simply do that. If the printer
  311. cannot be fixed create a shell script filter that reads:
  312.  
  313.      #!/bin/sh
  314.      if [ "$1" = -c ]; then
  315.        cat
  316.      else
  317.        sed -e s/$/^M/
  318.      fi
  319.      # the ``echo -ne'' assumes that /bin/sh is really bash
  320.      echo -ne \\f
  321.  
  322.    Where `^M' is a carriage return character not a `^' followed by a
  323. `M'.  To type `^M' in Emacs use the sequence `C-q C-m' and in vi use
  324. `C-v C-m'.  Conventionally this script is called `/usr/lib/lpf'. If you
  325. have more than one such script a better idea is to keep them in a
  326. subdirectory, say `/usr/lib/lpd/'. The test of `$1' allows the
  327. insertion of carriage returns to be switched off by `lpr -l'.
  328.  
  329.    Install this filter as the `if' filter by putting
  330. `:if=/usr/lib/lpf:' (or whatever) in your `/etc/printcap' entry for the
  331. printer.
  332.  
  333.    Alternatively your printer may have an escape sequence that will set
  334. the way it handles linefeed characters. A simple filter that uses an
  335. `echo -ne' command to send this sequence may be appropriate.
  336.  
  337.      #!/bin/sh
  338.      # Filter for HP printers to treat LF as CRLF
  339.      # the ``echo -ne'' assumes that /bin/sh is really bash
  340.      echo -ne \\033\&k2G
  341.      cat
  342.      echo -ne \\f
  343.  
  344. 3.12 Resetting the printer between each file printed
  345. ====================================================
  346.  
  347.    Either make your filters do it or define the `tr' "capability" in
  348. `/etc/printcap' to be your printer's font reset command. For details of
  349. the format of this string see the question on the format of printcap.
  350. This may not work if a printout crashes in the middle of an escape
  351. sequence - putting a lot of `^@' on the front may help but this
  352. probably won't be enough it you were printing raster graphics when the
  353. filter died.
  354.  
  355. 3.13 Preventing formfeed after each file printed
  356. ================================================
  357.  
  358.    If you don't have an `if' specified in `/etc/printcap' then `lpd'
  359. will automatically put a formfeed at the end of each file. If you're
  360. using a filter then it's up to the filter to decide if it wants to put
  361. a formfeed. To disable formfeed completely if you don't have an `if'
  362. put `:ff=:' in your `/etc/printcap'.  But please note this suppresses
  363. the formfeed that would usually be printed if a filter dies. If you
  364. want formfeeds after text printouts but not on printouts printed with
  365. `lpr -l' then create the following `if' filter:
  366.  
  367.      #!/bin/sh
  368.      # the ``echo -ne'' assumes that /bin/sh is really bash
  369.      cat
  370.      if [ "$1" != -c ]; then
  371.        echo -ne \\f
  372.      fi
  373.  
  374.    If you want a formfeed after `lpr -l' to be optional you can misuse
  375. the `-i' switch to suppress the formfeed with the following trick (after
  376. all `lpr -i -l' would usually not be implemented).
  377.  
  378.      #!/bin/sh
  379.      cat
  380.      # use lpr -i -l to print raw without trailing formfeed
  381.      if [ "$1" != -c -o "$4" = -i0 ]; then
  382.        # the ``echo -ne'' assumes that /bin/sh is really bash
  383.        echo -ne \\f
  384.      fi
  385.  
  386. 3.14 Printing with lpd to a serial port
  387. =======================================
  388.  
  389.    The first if lpd complains about "ioctl(TIOCEXCL)" being
  390. unimplemented you need a version of lpd that doesn't care (eg.
  391. lpd-590p2)
  392.  
  393.    There are two sets of flags which you will need to set, plus the baud
  394. rate (Note: the `fc' flag setting seems to override the `br#'
  395. capability, so be sure to set that correctly as well as the `br#'!).
  396.  
  397.    Each of the flags can have bits set and cleared. Clearing is done
  398. first, so specify the clear flags (`fc#' and `xc#') before the set
  399. flags (`fs' and `xs').
  400.  
  401.    Setting the `br#' capability is self-explanatory. Example: `br#9600'
  402.  
  403.    It is very easy to translate from `stty' settings to printcap flag
  404. settings. If you need to, see the man page for stty now.
  405.  
  406.    Use stty to set up the printer port so that you can cat a file to it
  407. and have it print correctly. Here's what `stty -a' looks like for my
  408. printer port:
  409.  
  410.      dina:/usr/users/andy/work/lpd/lpd# stty -a < /dev/ttyS2
  411.      speed 9600 baud; rows 0; columns 0; line = 0;
  412.      intr = ^C; quit = ^\; erase = ^?; kill = ^U; eof = ^D; eol = <undef>;
  413.      eol2 = <undef>; start = ^Q; stop = ^S; susp = ^Z; rprnt = ^R; werase = ^W;
  414.      lnext = ^V; min = 1; time = 0;
  415.      -parenb -parodd cs8 hupcl -cstopb cread -clocal -crtscts
  416.      -ignbrk -brkint -ignpar -parmrk -inpck -istrip -inlcr
  417.      -igncr -icrnl ixon -ixoff -iuclc -ixany -imaxbel
  418.      -opost -olcuc -ocrnl -onlcr -onocr -onlret -ofill -ofdel nl0 cr0 tab0
  419.      bs0 vt0 ff0
  420.      -isig -icanon -iexten -echo -echoe -echok -echonl -noflsh -xcase -tostop
  421.      -echoprt -echoctl -echoke
  422.  
  423.    The only changes between this and the way the port is initialized at
  424. bootup are `-clocal', `-crtscts', and `ixon'. Your port may well be
  425. different depending on how your printer does flow control.
  426.  
  427.    Once you have your stty settings right, so that `cat file >
  428. /dev/ttyS2' (in my case) sends the file to the printer, look at the file
  429. `/usr/src/linux/include/linux/termios.h'. This contains a lot of
  430. `#define's and a few structs (You may wish to cat this file to the
  431. printer (you do have that working, right?) and use it as scratch paper
  432. - I (Andrew Tefft <teffta@engr.dnet.ge.com> did!). Go to the section
  433. that starts out
  434.  
  435.      /* c_cflag bit meaning */
  436.      #define CBAUD   0000017
  437.  
  438.    This section lists the meaning of the `fc#' and `fs#' bits.  You
  439. will notice that the names there (after the baud rates) match up with
  440. one of the lines of stty output. Didn't I say this was going to be easy?
  441.  
  442.    Note which of those settings are preceded with a - in your stty
  443. output. Sum up all those numbers (they are octal). This represents the
  444. bits you want to *clear*, so the result is your `fc#' capability.  Of
  445. course, remember that you will be setting bits directly after you
  446. clear, so you can just use `fc#0177777' (I do).
  447.  
  448.    Now do the same for those settings (listed in this section) which do
  449. not have a - before them in your stty output. In my example the
  450. important ones are CS8 (0000060), HUPCL (0002000), and CREAD (0000200).
  451. Also note the flags for your baud rate - mine is 0000015. Add those all
  452. up, and in my example you get 0002275. This goes in your `fs#'
  453. capability (`fs#02275' works fine in my example).
  454.  
  455.    Do the same with set and clear for the next section of the include
  456. file, "c_lflag bits". In my case I didn't have to set anything, so I
  457. just use `xc#0157777' and `xs#0'.
  458.  
  459.    Once your printcap is set up, try it out. If things don't work, see
  460. the next section.
  461.  
  462. 3.15 cat works to the serial port, but not lpd (1)
  463. ==================================================
  464.  
  465.    Generally getting lpd up and running is explained elsewhere, but if
  466. you are having trouble with serial port settings you can prevent `lpd'
  467. from trying to configure your port by treating you printer as one that
  468. does not present a normal device interface. See Also: Printers not in
  469. /dev.
  470.  
  471.   1. Set your printer (in your printcap) to `/dev/null1'. (`mknod
  472.      /dev/null1 c 1 3' because you don't want `/dev/null' to be opened
  473.      exclusively).
  474.  
  475.      remove the baud rate and flags settings from your printcap.
  476.  
  477.   2. Create a script such as this:
  478.  
  479.           #!/bin/sh
  480.           echo if: $* >> /var/spool/lpd/results
  481.           # /dev/lp is linked to /dev/ttyS2 which has the printer
  482.           exec your-old-input-filter $* > /dev/lp
  483.         ...or if you didn't have an old `if' installed...
  484.           #!/bin/sh
  485.           echo if: $* >> /var/spool/lpd/results
  486.           cat > /dev/lp
  487.           # the ``echo -ne'' assumes that /bin/sh is realy bash
  488.           echo -en \\f > /dev/lp
  489.  
  490.      Make sure it's world-executable and world-readable. Try out your
  491.      script (`/usr/lib/lpd/if < SOMEFILE') and see if it prints.
  492.  
  493.   3. Set the `if' capability in your printcap to call this script, e.g.
  494.      `if=/usr/lib/lpd/if'
  495.  
  496.   4. Use stty to correctly set your port settings. Try to print now.
  497.      You should be able to tell if things are being spooled, and things
  498.      *should* be printed, if your manual testing of the `if' script
  499.      works. But this is a kludge, so the idea is not to use the `if'
  500.      script.
  501.  
  502.    Assuming the above method using the `if' filter works and that you
  503. believe that you have specified what you think are the correct flags
  504. and baud rate in printcap; check `stty -a < /dev/ttyS2' (or whatever
  505. your printer port is).  If the settings are not correct, check your
  506. flags against your printout from termios.h. If the settings are *way*
  507. not correct, you may need a fixed lpd. The patch follows, and you can
  508. probably see why it's needed :-) Note: this patch is reversed and has
  509. already been applied (uh... unapplied :-) ) to lpd-590p2 so don't apply
  510. it if you already have that version or later.
  511.  
  512.    (the patch is coming in just a sec)
  513.  
  514.    When I was setting mine up, I followed a sequence like this:
  515.  
  516.      lprm WHATEVER # (make sure queue is empty and lpd is running)
  517.      stty CORRECT SETTINGS < /dev/ttyS2
  518.      lpr SOMETHING SMALL
  519.      stty -a < /dev/ttyS2  # (often had to ctrl-c out of this one)
  520.      
  521.      twiddle with flags
  522.      
  523.      lprm WHATEVER # make sure queue is empty again...
  524.  
  525.    Here's the patch (I it's reversed so apply it with `-R' - or, in
  526. practice, by hand!):
  527.  
  528.      -------------------------------Cut Here-------------------------------------
  529.      *** lpd-590/lpd/printjob.c  Thu Jul  8 20:56:59 1993
  530.      --- lpd-590/lpd/printjob.c~ Sat Feb 27 09:07:01 1993
  531.      ***************
  532.      *** 1271,1277 ****
  533.              }
  534.        #ifdef LINUX
  535.              ttybuf.c_cflag &= ~FC;          /* not quite right! */
  536.      !       ttybuf.c_cflag |= FS;           /* not quite right! */
  537.        #else
  538.              ttybuf.sg_flags &= ~FC;
  539.              ttybuf.sg_flags |= FS;
  540.      --- 1271,1277 ----
  541.              }
  542.        #ifdef LINUX
  543.              ttybuf.c_cflag &= ~FC;          /* not quite right! */
  544.      !       ttybuf.c_cflag |= ~FS;          /* not quite right! */
  545.        #else
  546.              ttybuf.sg_flags &= ~FC;
  547.              ttybuf.sg_flags |= FS;
  548.      -------------------------------Cut Here-------------------------------------
  549.  
  550. 3.16 Printers that are not simple devices
  551. =========================================
  552.  
  553.    [Firstly I'll explain the subject.] The most common example is a
  554. printer that is connected via a network in some strange way.  For
  555. example consider a printer connected to a host with which you can only
  556. communicate via E-mail.
  557.  
  558.    To use such a printer through `lpr' the `lp' capability of the print
  559. queue should be directed to a `/dev/null' type device (e.g. `mknod
  560. /dev/null1 c 1 3') but not `/dev/null' itself as `lpd' opens the device
  561. exclusively. Each filter must must explicitly uuencode and mail its
  562. output.
  563.  
  564.    In more complex cases if you already have an `if' or `of' filter for
  565. a strangely connected printer then other filters can pass their output
  566. to/through this filter to avoid duplication of effort.  In this case
  567. the `if' filter should usually be called with the `-c' switch to
  568. minimise the further manipulations if performs.
  569.  
  570.    I've heard someone has had some success trying something like this
  571. with Novell NetWare and the free mail transfer agent "Charon".
  572.  
  573. 3.17 Generating burst or banner pages
  574. =====================================
  575.  
  576.    For a simple text printer (in particular not PostScript) and a
  577. simple text banner simply take `:sh:' out of the printcap record. If you
  578. want to prevent the banner comming out in whatever font was last used
  579. on the printer then define the `tr' "capability" to be your printer's
  580. font reset command.
  581.  
  582.    If you want a fancy customised banner (or have a PostScript printer)
  583. leave `:sh:' in the printcap and make each of your filters print the
  584. banner. All the information to put on the banner is included in the
  585. filter's positional parameters.  RTFM(printcap) for details. [ If
  586. you're using <B.A.McCauley@bham.ac.uk>'s magic-filter package then call
  587. the code to print the banners from the config script. ]
  588.  
  589. 3.18 Spooling text to a PostScript printer
  590. ==========================================
  591.  
  592.    You need a filter based on a program that converts ascii to
  593. PostScript. The most well known of these is `enscript' but it's also
  594. the hardest to find (being non-free). Others include `a2ps',
  595. `nenscript', and `mpage'. See Also: Printing text via PostScript.
  596.  
  597. 3.19 Why graphics files are sometines truncated
  598. ===============================================
  599.  
  600.    This is usually because you've got a limit set on the maximum size
  601. file that can sit in the spool queue. Put `mx#0' in your printcap.
  602.  
  603. 3.20 Why `lpr -i' doesn't work
  604. ==============================
  605.  
  606.    To get `lpr -i' to work you need a filter installed as `if' that
  607. implements it.  The `-i' switch is simply passed on by `lpd' to the
  608. filter.  The filter called `lpf' that comes with `lpd' supports this
  609. feature but can only be used to print text.  If you whant to use this
  610. program but still want your filter to do some printer specific
  611. initialisation then write script thus:
  612.  
  613.      #!/bin/sh
  614.      # My initialisation stuff goes here
  615.      exec /usr/lib/lpf $*
  616.  
  617.    More reasonably you could have your filter script send the printer
  618. left margin sequence.
  619.  
  620.      #!/usr/bin/perl
  621.      # This example is in perl for a change because converting numbers
  622.      # to characters is tricky in shell script
  623.      
  624.      for ($i=0; !($_ = $ARGV[$i]) || !/^-i([0-9])+/; $i++) {}
  625.      
  626.      print pack("cAc",27,"l",$1);
  627.      
  628.      while (<STDIN>) { print; }
  629.  
  630. 3.21 Why `lpr -p' doesn't work?
  631. ===============================
  632.  
  633.    Because it's broken. `lpd' always thinks that the printer is 0
  634. characters wide regardless of what `/etc/printcap' or the `lpr'
  635. arguemnts say. The lpd-FAQ contained a patch but it has now been
  636. applied to lpd-590p1 and later. (Appologies to anyone who wanted this
  637. patch after the lpd-FAQ merged with printing-how.to. It was dropped in
  638. the mistaken belief that a new release of lpd-590 was iminent).
  639.  
  640.    One other thing: `lpd' calls `pr' by full pathname so if you keep
  641. `pr' somewhere different from `/usr/bin/pr' you will need a symlink.
  642. (Where `lpd' expects to find `pr' may vary from version to version).
  643.  
  644. 3.22 `lpc' and `lpq' warning of missing daemons
  645. ===============================================
  646.  
  647.    One `lpd' process runs all the time and it spawns children to handle
  648. each printer as needed. The health of the master daemon is not
  649. explicity reported by `lpc' but the absence of errors indicates that it
  650. is healthy. See Also: lpd not working. The `lpc stat' command will
  651. display the message "no daemon present" for each queue that is not
  652. actually printing at the time - this is completely normal. If printing
  653. has been disabled or the queue is empty then this is not an error
  654. condition. `lpq' is even more alarmist and will say "Warning: no daemon
  655. present". If the daemon is absent when the queue has entries and has
  656. not been explicitly stopped then this warning probably indicates an
  657. error in a filter. Fix the filter then use `lpd up QUEUE-NAME' to
  658. restart it.
  659.  
  660.    Sometimes when shutting down a printer `lpc' will get confused and
  661. try to kill a non existant daemon. This leads to irritating but harmless
  662. error messages. In lpd-590p2 these are much rarer.
  663.  
  664. 3.23 Using `lpr' over a network
  665. ===============================
  666.  
  667.    To print on the printer listed as `foo' in the printcap on machine
  668. `bar.baz.net' from the machine `mine.baz.net' you put an entry like
  669. this in your `/etc/printcap' (on `mine.baz.net'):
  670.  
  671.      foo:lp=:rm=bar.baz.net:rp=foo:sd=/usr/lpd/spool/foo:
  672.  
  673.    and, of course, create the spool directory `/usr/lpd/spool/foo'.
  674.  
  675.    There's no point specifying filters and the like in
  676. `mine.baz.net:/etc/printcap' as it's the ones in
  677. `bar.baz.net:/etc/printcap' that will get used.
  678.  
  679.    On the machine `bar.baz.foo', you need to put `mine.baz.net' on a
  680. line by itself in either `/etc/hosts.equiv' or `/etc/hosts.lpd'; note
  681. that putting it in `/etc/hosts.equiv' will allow for unauthenticated
  682. logins as well as printing.  `/etc/hosts.lpd' is for printing only.
  683.  
  684.    The machines listed in `/etc/hosts.*' should be described canonical
  685. names or numbers as lpd starts with the IP address and performs a
  686. revervse DNS lookup to get the name. If you are not sure of cannonical
  687. name you can just list all the names you know for a machine. (If you
  688. have `dig' then the command `dig -x A.B.C.D' can be used to get the
  689. canonical name of IP address A.B.C.D.)
  690.  
  691.    If the printer server is not nunning a BSD style spooler then it
  692. should still be possible to get it to work but the authority files may
  693. have a different names or formats. For example Chris Nystrom
  694. <chrisn@medianet.com> found that he had to create a file on the remote
  695. machine called `/usr/spool/lp/admins/lp/Systems' that listed his Linux
  696. box's name. We do not know if this is a SYSV thing or something
  697. exclusive to dynix/ptx 2.0.3 that he is using on his Sequent.
  698.  
  699.    If you can't get remote printing to work thrugh lpd you may be able
  700. to simply use remote command exectution like this:
  701.  
  702.      rsh bar.baz.net "lp -dlp" < FILE
  703.  
  704.    This example would be for a remote system using a SYSV type printing
  705. system on host `bar.baz.net'.
  706.  
  707. 3.24 Writing lpd filters
  708. ========================
  709.  
  710.    In normal Un*x terminology, filters are just programs (so they must
  711. have execute permission) that read a stream from their standard input
  712. and write to their standard output.
  713.  
  714.    lpd filters are filters in the sense that thay read STDIN and write
  715. to STDOUT, but are unusual in that they may assume that their standard
  716. input is a random acess file file and may perform lseek() operations on
  717. it.
  718.  
  719.    All lpd filters have a common command line syntax (or more often
  720. simply ignore command line parameters). For details of the command line
  721. parameters RTFM(printcap).
  722.  
  723.    If you want to write a shell script filter it must have a #!/bin/sh
  724. (or perl or csh) header.  Here is the generic form of a filter to
  725. accept PostScript.
  726.  
  727.      #!/bin/sh
  728.      /PATH.../gs -q -dSAFER -dNOPAUSE -r??? -sDevice=?????? -sOutputFile=- -
  729.  
  730.    Place the full pathname of the script as one of the filters (but not
  731. `of'!) parameter in the printcap for your printer.  I suggest putting
  732. such scripts in `/usr/lib/lpd/'. It is also usual to keep filters in
  733. the spool directories but this goes against normal practice of keeping
  734. programs and data neatly apart.  (`-dSAFER' attempts to protect against
  735. PostScript interpreter security holes, `-q' and `-dNOPAUSE' make it run
  736. nonstop, and Device is the appropriate special file for your printer).
  737.  
  738.    Here is an Epson FX-80 dvi filter using ghostscript:
  739.  
  740.      #!/bin/sh
  741.      /usr/TeX/bin/dvips -f | \
  742.                    /usr/bin/gs -q -dSAFER -sDEVICE=eps9high -r120x216 \
  743.                    -dNOPAUSE -sOutputFile=- -
  744.  
  745.    More tools useful for making filters are described elsewhere in this
  746. document.
  747.  
  748. 3.25 Debuging lpd filters
  749. =========================
  750.  
  751.    It's easier to debug filters if you test them in an immediate shell
  752. before you install them. (If your filter makes use of its command line
  753. arguments you'll have to specify them too).  `my-new-filter <FILE
  754. >/dev/lp1'
  755.  
  756.    A trick most people find useful when testing filters that make use of
  757. their command line arguments is to include `echo $* >>/tmp/filter-log'
  758. near the top of the script.
  759.  
  760.    If the filter works when you test it but still doesn't work when
  761. called by `lpd' then you may have forgotten the `#!/bin/sh' header. You
  762. may also need to set PATH within the script since the daemon's PATH may
  763. not have everything you need. Note also that the filter is run with
  764. uid=daemon so any programs it calls sould be world executable.
  765.  
  766. 3.26 Output (`of') filters
  767. ==========================
  768.  
  769.    Never use these. (Well strictly speaking there are circumstances but
  770. you're unlikey to meet them). Recently (early '94) there has been a
  771. spate of preople on c.o.l.help advokating the use of output filters.
  772. Using `of' filters means that if a printout is queued while another is
  773. already printing the 2 will be run together with a form-feed between.
  774. Any printer initialisation or file type detection will therfore not be
  775. performed for the second file and it will probably be printed
  776. incorrectly. There are other more subtle ways in which output filters
  777. can do unexpected things. IMHO: If using an output filter is the
  778. answer, it was probably a silly question.
  779.  
  780. This is Info file Printing-HOWTO.info, produced by Makeinfo-1.55 from
  781. the input file printing.texinfo.
  782.  
  783.    A guide to printing and previewing files under the Linux operating
  784. system.
  785.  
  786.    Copyright (C) 1994 by Grant Taylor and Brian McCauley
  787.  
  788. 3.27 Getting filters for given printers
  789. =======================================
  790.  
  791.    From: B.A.McCauley@bham.ac.uk (Brian McCauley)
  792.  
  793.    Because writing a filter usually takes about 10 minutes once you've
  794. found the right program (`gs', `dvilj' etc.) there's little call for
  795. ftp archives of printer filters but we are thinking of creating an
  796. extensive example file to go with this document.
  797.  
  798.    If you already have a program to print, say, DVI on your printer by
  799. some mechanism then making it into a filter is usually a matter of
  800. writting trivial shell script See Also: Writing lpd filters. If the
  801. program you are using insists on reading a names file as input see the
  802. next question. Text mode filters are trivial too (see this HOWTO)
  803. unless you want lpr to have a choice of fonts in which case they are
  804. slightly harder than trivial.  You will probably want to insert and
  805. `echo -ne' command at the beginning and end of your filter to set up
  806. the font etc to your liking.
  807.  
  808. 3.28 Filters from programs that won't read STDIN
  809. ================================================
  810.  
  811.    Some of the programs that are used in writing `lpd' filters are not
  812. capable of taking their input from their standard input. For example
  813. `dvilj2p' insists on a named file as its input (and what's more expects
  814. one with a `.dvi' suffix) so do this:
  815.  
  816.      #!/bin/sh
  817.      ln -s /proc/self/fd/0 /tmp/$$.dvi
  818.      dvilj2p /tmp/$$
  819.      rm /tmp/$$.dvi
  820.  
  821.    Note: If it wasn't for the fact that `dvilj2p' adds a `.dvi' suffix
  822. you wouldn't need the temporary symlink and could just specify
  823. `/proc/self/fd/0' directly. People who use this trick often usually
  824. permanently `ln -s /proc/self/fd/0 /dev/stdin'. If you're highly
  825. security concious and don't allow access to `/proc' you'll need to
  826. create a temporary file.
  827.  
  828. 3.29 Having many filters
  829. ========================
  830.  
  831.    Historically the `lpr' command was created to support a finite set
  832. of possible file types. You can, in fact, use any of the filters for any
  833. reason. If you're never going to use Benson Varian raster files you
  834. could use the `-v' switch for GIF files. You could even use `-d' for
  835. low res and `-v' for high res. Remember that if you create a filter for
  836. a file format that takes a long time to process then your printer may
  837. sit idle between print jobs even when there are things in the queue.
  838.  
  839.    If you are on a network remember that the filter setups go on the
  840. print server.  One way to avoid running out of filter options is to
  841. define several logical printers in `/etc/printcap' that all point to the
  842. same physical one and put each filter in the `if' field of a different
  843. printcap entry. This has the advantage that you can set the `PRINTER'
  844. enviroment variable to choose your filter rather than having to specify
  845. it on the command line each time. One small problem with this is that
  846. you have no control over the order in which files from separate queues
  847. are printed.
  848.  
  849.    Another (and these days more common) way to avoid running out of
  850. possible types is to use magic filters.
  851.  
  852. 3.30 Magic Filters
  853. ==================
  854.  
  855.    Magic filters deduce their input files' types from `magic numbers'
  856. (distictive byte patterns at particular offsets).  Magic filters are
  857. usually perl scripts, shell scripts or C programs that simply identify
  858. the file type then call the appropriate non-magic filter. Blatent plug
  859. :-) Brian has a generic magic filter bash script that selects the right
  860. filter to use based on the output of the `file' command. With a
  861. suitable magic filter (and 3 associated non-magic filters) you can do
  862. things like:
  863.  
  864.      lpr -d file1.dvi file2.div.Z file3.ps file4.texinfo.gz
  865.  
  866.    (BTW confguring `lpr' to handle texinfo files is getting a bit
  867. silly).
  868.  
  869.    This is now on the mailserver or at:
  870. `tsx-11.mit.edu:pub/linux/sources/usr.bin/magic-filter-0.4.tar.gz'
  871. (Although the release number will possibly change in future).
  872.  
  873.    `apsfilter' is a rather easier to use shell script that requires no
  874. additional filters and which is pre-configured for HP compatible laser
  875. printers. This is also available on the mailserver.
  876.  
  877.    An example written in C, which may be easily adapted to most
  878. installations is available from the printing mail server as `lpr_if.c'.
  879.  
  880.    Magic filters should never specified as `of' as the output filter
  881. only gets called once if a number of files are printed without a gap.
  882. There are other more subtle problems too using `of'.
  883.  
  884.    IMHO (Brian) magic filters as `if' are inelegant as they may prevent
  885. you, say, listing a PostScript or nroff file. (Most people disagree
  886. with me on this point.)
  887.  
  888. 3.31 Magic Filter Examples
  889. ==========================
  890.  
  891.    The following is an example of a magic shell script which should take
  892. either PostScript or text and deal with it:
  893.  
  894.      #!/bin/sh
  895.      # This is based on a script I received from Scott Doty and which was
  896.      # written by Keith Walker.  Keith's script made use of the fact that
  897.      # lpd passes options to if:
  898.      #
  899.      #  <if> -w<width> -l<length> -i<indent> -n <user> -h <host> <accountingfile>
  900.      #
  901.      # to print text out well at any size.  This one does not.  These options
  902.      # are also handy if you want to do your own snazzy header page, much
  903.      # like NeWSPrint from Sun does (although running PostScript through
  904.      # the display server to get it interpreted is a bit much :)
  905.      #
  906.      #
  907.      # gs will reset the printer anyway, so the this text setup doesn't matter.
  908.      # setup should include the escape code for \n conversion, if applicable.
  909.      #
  910.      printf "<printer setup for text printing (escape codes, etc)>"
  911.      
  912.      read first_line
  913.      first_two_chars=`expr $first_line : '\(..\)'`
  914.      
  915.      if [ "$first_two_chars" = "%!" ]; then # it's PostScript
  916.      
  917.              /usr/bin/gs -dSAFER -dNOPAUSE -q -sDEVICE=??????? -sOutputFile=- -
  918.      
  919.      else # it's plain text
  920.      
  921.              echo -n $first_line
  922.              cat
  923.              printf "\014"
  924.      
  925.      fi
  926.  
  927.    Note that for the paranoid, shell scripts run as someone other than
  928. the user are sometimes a security hole, but this is not the case with
  929. lpd filters as the script's environment is not under the control of the
  930. potential cracker.
  931.  
  932. 4 Previewing
  933. ************
  934.  
  935.    These sections describe various ways to preview things under Linux -
  936. that is, how to view them in a way approximating their final form
  937. without printing them out.
  938.  
  939. 4.1 ghostview
  940. =============
  941.  
  942.    Ghostview, a companion program for `gs', previews PostScript on an X
  943. display.  It also lets you select individual or ranges of pages from a
  944. PostScript document to print using `lpr'.  The new version, 1.5, has
  945. fixed a few glitches which never bothered me but may make a difference
  946. to you.  It also calls `gs' with the `-dSAFER' option and has a few
  947. more resource and command-line options relative to 1.4.1.  The real
  948. installation is from:
  949. `prep.ai.mit.edu:/pub/gnu/ghostview-XXX.tar.gz'
  950.  
  951.    It builds out of the box.  Ghostview requires `gs' to work.  The new
  952. version of `gs', 2.6.x, will use X display fonts in an effort to
  953. improve legibility at the low resolutions of a video monitor (a
  954. previous failing of this pair relative to commercial display-PostScript
  955. based systems).  This works very well for me at least, at the expense
  956. of exact character positioning (X fonts have different widths).  In
  957. fact, I thought that Ghostview looks better than Sun's pageview the
  958. other day when I looked at the same page in oth programs side-by-side.
  959. Ghostview/Ghostscript also has much more intelligent color handling
  960. than pageview.  You might wish to let `gs' render some Type 1 fonts you
  961. install instead of using platform fonts (or the awful fonts `gs' comes
  962. with.  To do this while in Ghostview (or in any situation involving the
  963. X11 driver), place `ghostscript.useExternalFonts: false' in your
  964. `.Xdefaults' file, and the platform fonts will not be used.
  965.  
  966.    This is part of a message posted to gnu.ghostscript.bug by Tim
  967. Theisen <ghostview@cs.wisc.edu>:
  968.      (note that the usual Linux X-server, XFree, is simply an enhanced
  969.      version of MIT's effort at an i386 X-server (X386), and does
  970.      contain the X11R5 Type 1 rasterizer which I beleive was
  971.      contributed by IBM.)
  972.  
  973.      Ghostscript now uses the X Toolkit to pick up X Resources.  Now
  974.      ghostscript uses the standard X rules that allow more specific
  975.      resources to override less specific ones giving users the full
  976.      power of X resources to control the X11 driver.  It also allows
  977.      system administrators to establish an application defaults file
  978.      with resources specific to their ghostscript installation.
  979.  
  980.      The customization choices mentioned in make.doc have been moved
  981.      into X resources and are now configured at run time rather than
  982.      compile time.  Sorry, this section of make.doc did not get revised
  983.      for the 2.6.1 release.
  984.  
  985.      If `useBackingPixmap' is set, ghostscript will attempt to allocate
  986.      a backing pixmap.  If one cannot be allocated, ghostscript will
  987.      issue a warning and ask for backing store instead.  (Since there
  988.      were insufficient resources for a backing pixmap, the X server may
  989.      not provide backing store either.)
  990.  
  991.      Color Handling was totally revamped for gs 2.6.
  992.  
  993.      Ghostscript first checks for a suitable standard colormap.  If you
  994.      have static colormap in your X server, it would be best to store a
  995.      standard colormap property on the root window describing the color
  996.      layout.  Ghostscript will then be able to take full advantage of
  997.      the device.  If you have a standard colormap installed,
  998.      ghostscript will start slightly faster since it does not have to
  999.      allocate colors for a cube or ramp.
  1000.  
  1001.      If no standard colormap is available, ghostscript will allocate an
  1002.      RGB cube or gray ramp.  Ghostscript tries for a 5x5x5 cube on a
  1003.      color device, and a 128 gray ramp on grayscale devices.  It will
  1004.      never ask for more than 1/2 of the colors for a RGB cube or gray
  1005.      ramp.  It also takes into account the number of significant bits
  1006.      per pixel.  (i.e.  It won't ask for 128 gray levels if you only
  1007.      have 16 available.)
  1008.  
  1009.      Ghostscript will attempt to allocate colors that are off the color
  1010.      cube/ramp as the picture is being rendered.  Ghostscript will keep
  1011.      track of 256 dynamic colors.  After all these are allocated,
  1012.      ghostscript asks the X server directly.
  1013.  
  1014.      The foreground and background color can be set explicitly.  This
  1015.      is important for the visually impaired and when using the ghostview
  1016.      widget.
  1017.  
  1018.      Color Resources:
  1019.  
  1020.        1. `palette'(`Palette'): Default value: `Color'.  Other
  1021.           allowable settings: `Grayscale', `Monochrome'.  The palette
  1022.           resource is used to restrict the palette used for display.
  1023.           One can set palette to `Grayscale' or `Monochrome' to see how
  1024.           a file would be rendered in grayscale or monochrome on a
  1025.           color display.  I use it to avoid dithering of gray- scale
  1026.           figures on a color display with 4-bit DACs.
  1027.  
  1028.        2. `maxGrayRamp'(`MaxGrayRamp'): Default value: 128.  Maximum
  1029.           number of gray levels that ghostscript will attempt to
  1030.           allocate.  (It won't try for more than this on an 8-bit
  1031.           pseudo color display even if you set it higher.)  Set this
  1032.           lower if you want a smaller ramp and would prefer ghostscript
  1033.           to use dynamic colors.
  1034.  
  1035.        3. `maxRGBCube'(`MaxRGBCube'): Default value: 5.  Maximum number
  1036.           of colors levels that ghostscript will attempt to allocate.
  1037.           (It won't try for more than this on an 8-bit pseudo color
  1038.           display even if you set it higher.)  Set this lower if you
  1039.           want a smaller ramp and would prefer ghostscript to use
  1040.           dynamic colors.
  1041.  
  1042.      I believe these values to be a good compromise between dynamic
  1043.      allocation and fall back onto a fairly good color cube for
  1044.      dithering.
  1045.  
  1046.      You can use the foreground and background colors to accomplish
  1047.      "reverse video".  However, if you have a grayscale device, it may
  1048.      be better to reverse the gray ramp using the following PostScript
  1049.      code fragment:
  1050.  
  1051.           [{1 exch sub} /exec load currenttransfer /exec load] cvx settransfer
  1052.  
  1053.      The X11 driver now supports native X11 fonts.  If you have
  1054.      installed the HP XLFD font extensions into your font or X server.
  1055.      Ghostscript will also be able to use platform fonts at rotations
  1056.      of 90 degrees, with mirroring, and anamorphic scaling.
  1057.  
  1058.      The X11 driver does most if its work silently.  You can get it to
  1059.      report when it is using an X11 font by setting the logExternalFonts
  1060.      boolean in your X resources.
  1061.  
  1062.      The X11 driver is setup to use the standard fonts distributed with
  1063.      X11R5.  We purchased the Adobe Type Manager and the Adobe Plus
  1064.      Pack.  These font packages give all the fonts normally found in
  1065.      the Apple LaserWriter Plus.  The X11 driver is setup to handle
  1066.      these fonts as well.  (They are a superset of the bitmap fonts
  1067.      distributed with X11.)
  1068.  
  1069.      You may set the regularFonts, symbolFonts, or dinbatFonts resources
  1070.      if you have different fonts available.  Each font name must have 7
  1071.      dashes or it will be ignored.  Minimize the use of wildcards to
  1072.      promote faster matching.  (I once encountered an X server that took
  1073.      many seconds to do a font lookup when wildcards were carelessly
  1074.      used.)
  1075.  
  1076.      There is a different list of fonts for each common encoding.
  1077.      Regular fonts may be accessed in standard or ISO Latin 1 encoding.
  1078.      The bdf files that are distributed with X11 are in the ISO Latin
  1079.      1 encoding.  This leaves out the ligatures.  Luckily, the
  1080.      ligatures are present in the bdf files, but are not given an
  1081.      encoding, essentially commenting them out.  You can use the
  1082.      `fixfont' program from the xproof distribution
  1083.      (`Ftp.Cs.Wisc.Edu:/Pub/X/Xproof.Tar.Z', or
  1084.      `Ftp.X.Org:/Contrib/Xproof.Tar.Z') to reencode the bdf files and
  1085.      build X11 fonts that contain the ligatures (i.e standard encoding).
  1086.  
  1087.      If you have the Type1 fonts mentioned above, and you installed the
  1088.      Type1 rasterizer into you font or X server, you can use the
  1089.      appended fonts.scale to name your fonts so that ghostscript can
  1090.      find them.
  1091.  
  1092.      Font resources:
  1093.  
  1094.        1. `useExternalFonts'(`UseExternalFonts'): Default value: true.
  1095.           This resource controls whether X11 fonts will be used.
  1096.  
  1097.        2. `useScalableFonts'(`UseScalableFonts'): Default value: true.
  1098.           This resource controls whether scalable fonts will be used.
  1099.           If you have an outline scaler in your X server, you should
  1100.           have this on.  If you have an X terminal, you may get
  1101.           slightly better performance with this on.  If you have to use
  1102.           the X11 bitmap scaler, turn this off.  Fonts scaled by the
  1103.           bitmap scaler look worse than the default ghostscript fonts.
  1104.  
  1105.        3. `logExternalFonts'(`LogExternalFonts'): Default value: false.
  1106.           Controls whether to report when X11 fonts are being used.
  1107.  
  1108.      The following fonts.scale makes all of the fonts of the Adobe Type
  1109.      Manager and Adobe Plus pack available in standard and ISO Latin 1
  1110.      encoding.  (We were able to purchase the above two packages at an
  1111.      educational discount price of $150.)
  1112.  
  1113. 70
  1114. agw_____.pfb -Adobe-ITC Avant Garde Gothic-Book-r-normal--0-0-0-0-p-0-iso8859-1
  1115. agwo____.pfb -Adobe-ITC Avant Garde Gothic-Book-o-normal--0-0-0-0-p-0-iso8859-1
  1116. agd_____.pfb -Adobe-ITC Avant Garde Gothic-Demi-r-normal--0-0-0-0-p-0-iso8859-1
  1117. agdo____.pfb -Adobe-ITC Avant Garde Gothic-Demi-o-normal--0-0-0-0-p-0-iso8859-1
  1118. bkl_____.pfb -Adobe-ITC Bookman-Light-r-normal--0-0-0-0-p-0-iso8859-1
  1119. bkli____.pfb -Adobe-ITC Bookman-Light-i-normal--0-0-0-0-p-0-iso8859-1
  1120. bkd_____.pfb -Adobe-ITC Bookman-Demi-r-normal--0-0-0-0-p-0-iso8859-1
  1121. bkdi____.pfb -Adobe-ITC Bookman-Demi-i-normal--0-0-0-0-p-0-iso8859-1
  1122. com_____.pfb -Adobe-Courier-Medium-r-normal--0-0-0-0-m-0-iso8859-1
  1123. coo_____.pfb -Adobe-Courier-Medium-o-normal--0-0-0-0-m-0-iso8859-1
  1124. cob_____.pfb -Adobe-Courier-Bold-r-normal--0-0-0-0-m-0-iso8859-1
  1125. cobo____.pfb -Adobe-Courier-Bold-o-normal--0-0-0-0-m-0-iso8859-1
  1126. hv______.pfb -Adobe-Helvetica-Medium-r-normal--0-0-0-0-p-0-iso8859-1
  1127. hvo_____.pfb -Adobe-Helvetica-Medium-o-normal--0-0-0-0-p-0-iso8859-1
  1128. hvb_____.pfb -Adobe-Helvetica-Bold-r-normal--0-0-0-0-p-0-iso8859-1
  1129. hvbo____.pfb -Adobe-Helvetica-Bold-o-normal--0-0-0-0-p-0-iso8859-1
  1130. hvn_____.pfb -Adobe-Helvetica-Medium-r-Narrow--0-0-0-0-p-0-iso8859-1
  1131. hvno____.pfb -Adobe-Helvetica-Medium-o-Narrow--0-0-0-0-p-0-iso8859-1
  1132. hvnb____.pfb -Adobe-Helvetica-Bold-r-Narrow--0-0-0-0-p-0-iso8859-1
  1133. hvnbo___.pfb -Adobe-Helvetica-Bold-o-Narrow--0-0-0-0-p-0-iso8859-1
  1134. ncr_____.pfb -Adobe-New Century Schoolbook-Medium-r-normal--0-0-0-0-p-0-iso8859-1
  1135. nci_____.pfb -Adobe-New Century Schoolbook-Medium-i-normal--0-0-0-0-p-0-iso8859-1
  1136. ncb_____.pfb -Adobe-New Century Schoolbook-Bold-r-normal--0-0-0-0-p-0-iso8859-1
  1137. ncbi____.pfb -Adobe-New Century Schoolbook-Bold-i-normal--0-0-0-0-p-0-iso8859-1
  1138. por_____.pfb -Adobe-Palatino-Medium-r-normal--0-0-0-0-p-0-iso8859-1
  1139. poi_____.pfb -Adobe-Palatino-Medium-i-normal--0-0-0-0-p-0-iso8859-1
  1140. pob_____.pfb -Adobe-Palatino-Bold-r-normal--0-0-0-0-p-0-iso8859-1
  1141. pobi____.pfb -Adobe-Palatino-Bold-i-normal--0-0-0-0-p-0-iso8859-1
  1142. sy______.pfb -Adobe-Symbol-Medium-r-normal--0-0-0-0-p-0-iso8859-1
  1143. tir_____.pfb -Adobe-Times-Medium-r-normal--0-0-0-0-p-0-iso8859-1
  1144. tii_____.pfb -Adobe-Times-Medium-i-normal--0-0-0-0-p-0-iso8859-1
  1145. tib_____.pfb -Adobe-Times-Bold-r-normal--0-0-0-0-p-0-iso8859-1
  1146. tibi____.pfb -Adobe-Times-Bold-i-normal--0-0-0-0-p-0-iso8859-1
  1147. zcmi____.pfb -Adobe-ITC Zapf Chancery-Medium-i-normal--0-0-0-0-p-0-iso8859-1
  1148. zd______.pfb -Adobe-ITC Zapf Dingbats-Medium-r-normal--0-0-0-0-p-0-iso8859-1
  1149. agw_____.pfb -Adobe-ITC Avant Garde Gothic-Book-r-normal--0-0-0-0-p-0-adobe-fontspecific
  1150. agwo____.pfb -Adobe-ITC Avant Garde Gothic-Book-o-normal--0-0-0-0-p-0-adobe-fontspecific
  1151. agd_____.pfb -Adobe-ITC Avant Garde Gothic-Demi-r-normal--0-0-0-0-p-0-adobe-fontspecific
  1152. agdo____.pfb -Adobe-ITC Avant Garde Gothic-Demi-o-normal--0-0-0-0-p-0-adobe-fontspecific
  1153. bkl_____.pfb -Adobe-ITC Bookman-Light-r-normal--0-0-0-0-p-0-adobe-fontspecific
  1154. bkli____.pfb -Adobe-ITC Bookman-Light-i-normal--0-0-0-0-p-0-adobe-fontspecific
  1155. bkd_____.pfb -Adobe-ITC Bookman-Demi-r-normal--0-0-0-0-p-0-adobe-fontspecific
  1156. bkdi____.pfb -Adobe-ITC Bookman-Demi-i-normal--0-0-0-0-p-0-adobe-fontspecific
  1157. com_____.pfb -Adobe-Courier-Medium-r-normal--0-0-0-0-m-0-adobe-fontspecific
  1158. coo_____.pfb -Adobe-Courier-Medium-o-normal--0-0-0-0-m-0-adobe-fontspecific
  1159. cob_____.pfb -Adobe-Courier-Bold-r-normal--0-0-0-0-m-0-adobe-fontspecific
  1160. cobo____.pfb -Adobe-Courier-Bold-o-normal--0-0-0-0-m-0-adobe-fontspecific
  1161. hv______.pfb -Adobe-Helvetica-Medium-r-normal--0-0-0-0-p-0-adobe-fontspecific
  1162. hvo_____.pfb -Adobe-Helvetica-Medium-o-normal--0-0-0-0-p-0-adobe-fontspecific
  1163. hvb_____.pfb -Adobe-Helvetica-Bold-r-normal--0-0-0-0-p-0-adobe-fontspecific
  1164. hvbo____.pfb -Adobe-Helvetica-Bold-o-normal--0-0-0-0-p-0-adobe-fontspecific
  1165. hvn_____.pfb -Adobe-Helvetica-Medium-r-Narrow--0-0-0-0-p-0-adobe-fontspecific
  1166. hvno____.pfb -Adobe-Helvetica-Medium-o-Narrow--0-0-0-0-p-0-adobe-fontspecific
  1167. hvnb____.pfb -Adobe-Helvetica-Bold-r-Narrow--0-0-0-0-p-0-adobe-fontspecific
  1168. hvnbo___.pfb -Adobe-Helvetica-Bold-o-Narrow--0-0-0-0-p-0-adobe-fontspecific
  1169. ncr_____.pfb -Adobe-New Century Schoolbook-Medium-r-normal--0-0-0-0-p-0-adobe-fontspecific
  1170. nci_____.pfb -Adobe-New Century Schoolbook-Medium-i-normal--0-0-0-0-p-0-adobe-fontspecific
  1171. ncb_____.pfb -Adobe-New Century Schoolbook-Bold-r-normal--0-0-0-0-p-0-adobe-fontspecific
  1172. ncbi____.pfb -Adobe-New Century Schoolbook-Bold-i-normal--0-0-0-0-p-0-adobe-fontspecific
  1173. por_____.pfb -Adobe-Palatino-Medium-r-normal--0-0-0-0-p-0-adobe-fontspecific
  1174. poi_____.pfb -Adobe-Palatino-Medium-i-normal--0-0-0-0-p-0-adobe-fontspecific
  1175. pob_____.pfb -Adobe-Palatino-Bold-r-normal--0-0-0-0-p-0-adobe-fontspecific
  1176. pobi____.pfb -Adobe-Palatino-Bold-i-normal--0-0-0-0-p-0-adobe-fontspecific
  1177. sy______.pfb -Adobe-Symbol-Medium-r-normal--0-0-0-0-p-0-adobe-fontspecific
  1178. tir_____.pfb -Adobe-Times-Medium-r-normal--0-0-0-0-p-0-adobe-fontspecific
  1179. tii_____.pfb -Adobe-Times-Medium-i-normal--0-0-0-0-p-0-adobe-fontspecific
  1180. tib_____.pfb -Adobe-Times-Bold-r-normal--0-0-0-0-p-0-adobe-fontspecific
  1181. tibi____.pfb -Adobe-Times-Bold-i-normal--0-0-0-0-p-0-adobe-fontspecific
  1182. zcmi____.pfb -Adobe-ITC Zapf Chancery-Medium-i-normal--0-0-0-0-p-0-adobe-fontspecific
  1183. zd______.pfb -Adobe-ITC Zapf Dingbats-Medium-r-normal--0-0-0-0-p-0-adobe-fontspecific
  1184.  
  1185. 4.2 gspreview
  1186. =============
  1187.  
  1188.    This is another front-end for Ghostscript.  I have gotten and built
  1189. it, and actually preferred the user interface, but it had a few bugs.
  1190. It didn't seem as full-featured as ghostview, though.  (Not that there
  1191. are all *that* many features in ghostview, but it does its job well).
  1192. `ftp.x.org:/contrib/gspreview...'
  1193.  
  1194. 4.3 xdvi
  1195. ========
  1196.  
  1197.    A beautifully legible previewing program for dvi with a handy
  1198. zoom+pan feature.  Will not interpret PostScript specials, which are
  1199. understood only by `dvips' (back to the compiler, object file, and now
  1200. linker analogy :-)  To view a file, do `xdvi file.dvi'.  This comes
  1201. with either TeX or X in most distributions.  Either way, you've
  1202. probably got one.  If not, look in `ftp.x.org:/contrib/'.
  1203.  
  1204. 4.4 xtex
  1205. ========
  1206.  
  1207.    Xtex is similar in purpose to xdvi.  I have tried to build it under
  1208. Linux and failed.  It is available as:
  1209. `ftp.x.org:/contrib/xtex-2.18.5.tar.z'
  1210.  
  1211. 4.5 gxditview
  1212. =============
  1213.  
  1214.    Ditview produces a preview version of `troff' source using X fonts.
  1215. `groff -TX100 -mandoc MAN PAGE' will run gxditview to show you a
  1216. typeset version of the man page.  `-TX75' is the same thing, but tiny.
  1217. Most distributions don't have a working one at all.  A good one comes
  1218. with the source to `groff', which you might want to get anyway for the
  1219. additional drivers (some distributions are missing some, including
  1220. PostScript).
  1221. `prep.ai.mit.edu:/pub/gnu/groff-XXXX.tar.z'
  1222.  
  1223. 4.6 non-X previewing
  1224. ====================
  1225.  
  1226.    Ghostscript comes with pc video hardware drivers, but under un*x
  1227. these are not a good thing.  However, there are `gs' binaries around
  1228. which will use the Linux VGA library (`svgalib').  The Ghostscript
  1229. device for this is called linux, thus `gs -sDEVICE=linux file.ps' will
  1230. show you an image of the PostScript.  The environment variable
  1231. `GSVGAMODE' is important for this.  Set it to the nuber of the video
  1232. mode you want, taken from the vga.h which comes with vgalib.
  1233.  
  1234.    If you need this driver, a patch to put in Linux svgalib is available
  1235. from the printing mail server or as:
  1236.      ws105.zfn.uni-bremen.de:/pub/gs261-linuxdriver.sh
  1237.      ws105.zfn.uni-bremen.de:/pub/gs261-svgalib.tar.gz
  1238.  
  1239.    Another possibly different svgalib patch is found in:
  1240. `ftp.cdrom.com:/pub/linux/misc'
  1241.  
  1242.    The plain vgalib driver is available on Sunsite.
  1243.  
  1244.    Texmgr is a program which will preview dvi under MGR.  I don't
  1245. beleive that it currently works under Linux MGR, but if it does, MGR
  1246. uses sufficiently less memory and disk that this might be an attractive
  1247. option for some.
  1248.  
  1249.    dvgt is a program which will preview dvi with Linux svgalib, or on
  1250. one of several types of graphics terminals including vt, tek, or a PC
  1251. with MS-Kermit.  It is available on sunsite.
  1252.  
  1253. 5 Ascii Translation
  1254. *******************
  1255.  
  1256.    These sections describe various programs which can generate plain
  1257. ascii from some file formats.
  1258.  
  1259. 5.1 from TeX
  1260. ============
  1261.  
  1262.    Lametex will generate ascii from TeX source.  It is available as:
  1263. `sunsite.unc.edu:/pub/Linux/apps/tex/lametex.tar.z'
  1264.  
  1265.    LaTeX is used by the Linux Doc Projext to generate text versions of
  1266. their manuals.  I don't know where to find it.
  1267.  
  1268. 5.2 from dvi
  1269. ============
  1270.  
  1271.    `dvi2tty' is a program which will process dvi into text.  Aparently,
  1272. it will also make an effort at reproducing graphics as well.  I do not
  1273. know where to find it.
  1274.  
  1275. 5.3 from PostScript
  1276. ===================
  1277.  
  1278.    Ghostscript 2.6.1 comes with a script file which will use `gs' to
  1279. extract just the text from a ps file, called `ps2ascii'.  (*note
  1280. PostScript., for information above for where it can be found).
  1281. Further documentation is in the Ghostscript 2.6.1 distribution files
  1282. `gs_2asc.ps' and `use.doc'
  1283.  
  1284. 5.4 from troff
  1285. ==============
  1286.  
  1287.      groff -Tascii or -Tlatin1 ...
  1288.  
  1289. 5.5 from ascii/latin1
  1290. =====================
  1291.  
  1292.    The GNU program `recode' handles conversion between various forms of
  1293. straight text encoding, ie from Latin-1 to ASCII.  This is available on
  1294. prep.ai.mit.edu.
  1295.  
  1296. --
  1297. Unless otherwise stated, Linux HOWTO documents are copyrighted by their
  1298. respective authors. Linux HOWTO documents may be reproduced and distributed 
  1299. in whole or in part, in any medium physical or electronic, without permission 
  1300. of the author. Translations and derivative works are similarly permitted 
  1301. without express permission. Commercial redistribution is allowed and 
  1302. encouraged; however, the author would like to be notified of any such 
  1303. distributions. 
  1304.  
  1305. In short, we wish to promote dissemination of this information through as
  1306. many channels as possible. However, we do wish to retain copyright on the
  1307. HOWTO documents, and would like to be notified of any plans to redistribute
  1308. the HOWTOs. If you have questions, please contact Matt Welsh, the Linux
  1309. HOWTO coordinator, at mdw@sunsite.unc.edu.
  1310.  
  1311.